package com.ruoyi.api.client.api;

import com.ruoyi.api.client.domain.dto.FeedbackDto;
import com.ruoyi.api.client.domain.vo.*;
import com.ruoyi.api.client.service.IClientCmsService;
import com.ruoyi.cms.domain.CmsArticle;
import com.ruoyi.cms.domain.CmsMessage;
import com.ruoyi.common.annotation.SaClientCheckLogin;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description 客户端内容管理模块API
 * @Author zouhuu
 * @Date 2022/8/5 13:56
 */
@RestController
@RequestMapping("/api/client/cms")
@Api(tags = "客户端-内容模块API")
public class CmsApi extends BaseController {

    @Autowired
    private IClientCmsService clientCmsService;

    @SaClientCheckLogin
    @ApiOperation("意见反馈")
    @PostMapping("/feedback")
    public R feedback(@RequestBody FeedbackDto feedbackDto) {
        return clientCmsService.feedback(feedbackDto);
    }

    @SaClientCheckLogin
    @ApiOperation("意见反馈列表")
    @GetMapping("/feedback/list")
    public R<List<CmsFeedbackVo>> feedbackList() {
        return clientCmsService.feedbackList();
    }

    @SaClientCheckLogin
    @ApiOperation("意见反馈详情")
    @GetMapping("/feedback/detail")
    @ApiImplicitParam(name = "feedbackId", value = "反馈ID", dataType = "Long", required = true)
    public R<CmsFeedbackVo> feedbackDetail(Long feedbackId) {
        return clientCmsService.feedbackDetail(feedbackId);
    }

    @SaClientCheckLogin
    @ApiOperation("意见反馈删除")
    @GetMapping("/feedback/del")
    @ApiImplicitParam(name = "feedbackId", value = "反馈ID", dataType = "Long", required = true)
    public R<CmsFeedbackVo> feedbackDel(Long feedbackId) {
        return clientCmsService.feedbackDel(feedbackId);
    }

    @ApiOperation("平台文档")
    @GetMapping("/doc/info")
    @ApiImplicitParam(name = "docId", value = "文档ID 如协议、关于我们等信息", dataType = "Long", required = true)
    public R<CmsDocumentVo> docInfo(Long docId) {
        return clientCmsService.docInfo(docId);
    }

    @ApiOperation("帮助文档分类详情")
    @GetMapping("/help/category")
    @ApiImplicitParam(name = "categoryId", value = "帮助文档分类ID", dataType = "Long", required = true)
    public R<CmsHelpCategoryVo> helpCategoryDetail(Long categoryId) {
        return clientCmsService.helpCategoryDetail(categoryId);
    }

    @ApiOperation("帮助文档列表")
    @GetMapping("/help/list")
    @ApiImplicitParam(name = "categoryId", value = "帮助文档分类ID", dataType = "Long", required = true)
    public R<List<CmsHelpVo>> helpList(Long categoryId) {
        return clientCmsService.helpList(categoryId);
    }

    @ApiOperation("帮助文档详情")
    @GetMapping("/help/detail")
    @ApiImplicitParam(name = "helpId", value = "帮助文档ID", dataType = "Long", required = true)
    public R<CmsHelpVo> helpDetail(Long helpId) {
        return clientCmsService.helpDetail(helpId);
    }

    @ApiOperation("文章分类")
    @GetMapping("/article/category")
    public R<CmsArticleCategoryVo> articleCategory() {
        return clientCmsService.articleCategory();
    }

    @ApiOperation("文章首页")
    @GetMapping("/article/home")
    public R<CmsArticleHomeVo> articleHome() {
        return clientCmsService.articleHome();
    }

    @ApiOperation("文章列表")
    @GetMapping("/article/list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "分页编号", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "pageSize", value = "分页数量", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "categoryId", value = "帮助文档ID", dataType = "Long", required = true)
    })
    public TableDataInfo articleList(Long categoryId) {
        CmsArticle cmsArticle = new CmsArticle();
        cmsArticle.setCategoryId(categoryId);
        startPage();
        List<CmsArticleVo> cmsArticleVos = clientCmsService.articleList(cmsArticle);
        return getDataTable(cmsArticleVos);
    }

    @ApiOperation("文章详情")
    @GetMapping("/article/detail")
    @ApiImplicitParam(name = "articleId", value = "文章ID", dataType = "Long", required = true)
    public R<CmsArticleVo> articleDetail(Long articleId) {
        return clientCmsService.articleDetail(articleId);
    }



    @ApiOperation("消息列表")
    @GetMapping("/msg/lsit")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "分页编号", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "pageSize", value = "分页数量", dataType = "Integer", required = true)
    })
    public R msgList() {
        startPage();
        //List<CmsMessage> cmsMessages = clientCmsService.msgList(new CmsMessage());
        return clientCmsService.msgList(new CmsMessage());
    }

    @ApiOperation("消息阅读")
    @GetMapping("/msg/read")
    public R msgDetail(Long msgId) {
        return clientCmsService.msgDetail(msgId);
    }

}
